package eu.boss.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.codehaus.jackson.annotate.JsonIgnore;

/**
 * Describes a PlayersList. the same as the server
 * @author Arnaud
 */

public class PlayerList implements Serializable{

	private static final long serialVersionUID = -8977621090496247015L;
	private List<Player> mPlayers;

	public PlayerList(PlayerList p)
	{
		mPlayers = new ArrayList<Player>();
		for (int i=0; i<p.getPlayers().size(); i++)
		{
			mPlayers.add(p.getPlayers().get(i));
		}
	}
	
	public PlayerList(){
		mPlayers = new ArrayList<Player>();
	}
	
	public List<Player> getPlayers() {
		return mPlayers;
	}

	public void setPlayers(List<Player> players) {
		this.mPlayers = players;
	}
	
	/**
	 * Sort playerlist by ratio
	 */
	public void sort()
	{
		Collections.sort(mPlayers);
	}
	
	
	/**
	 * reinitialize every single player of the list
	 */
	@JsonIgnore
	public void reinitList(){
		for (int i=0; i<mPlayers.size(); i++)
		{
			mPlayers.get(i).reInit();
		}
	}
	
	
	/**
	 * delete every single player of the list
	 */
	@JsonIgnore
	public void deletePlayers(){
		mPlayers.clear();
	}

}
